cmake_minimum_required(VERSION 3.0.0)
project(ccengine VERSION 1.0.0)

aux_source_directory(src SOURCE_DIR)

if (CMAKE_JS_VERSION)
	list(REMOVE_ITEM SOURCE_DIR "src/engine_jni.cpp")
	add_library(${PROJECT_NAME} SHARED ${SOURCE_DIR})
	set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
	include_directories(${CMAKE_JS_INC})
	if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
		set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
	endif()
	target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
else()
	list(REMOVE_ITEM SOURCE_DIR "src/engine_v8.cpp" "src/engine_v8.h")
	find_package(JNI)
	if (DEFINED JNI_INCLUDE_DIRS)
		include_directories(${JNI_INCLUDE_DIRS})
	else()
		list(REMOVE_ITEM SOURCE_DIR "src/engine_jni.cpp")
	endif()
	add_library(${PROJECT_NAME} SHARED ${SOURCE_DIR})

	enable_testing()
	add_subdirectory(test)
endif()

# set(CPACK_PROJECT_NAME ${PROJECT_NAME})
# set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
# include(CPack)
